package com.sfh.cpc.home.model;

import com.sfh.cpc.com.entity.ENote;
import com.sfh.cpc.com.entity.EUser;
import com.sfh.cpc.com.entity.RspBase;
import com.sfh.cpc.com.entity.RspPage;
import com.sfh.cpc.com.req.ReqPageCharm;
import com.sfh.cpc.com.req.ReqPageWealth;
import com.sfh.cpc.com.req.ReqWelfareNote;
import com.sfh.lib.exception.HandleException;
import com.sfh.lib.mvvm.service.BaseViewModel;
import com.sfh.lib.rx.IResult;

/**
 * 功能描述: TODO
 *
 * @author SunFeihu 孙飞虎
 * @date 2018/9/5
 */
public class RankingModel extends BaseViewModel implements IResult<RspBase<RspPage<EUser>>> {

    public void pageCharm(int nowPage) {
        this.execute(new ReqPageCharm(nowPage), this);
    }

    public void pageWealth(int nowPage) {
        this.execute(new ReqPageWealth(nowPage), this);
    }

    @Override
    public void onSuccess(RspBase<RspPage<EUser>> rspPageRspBase) throws Exception {
        if (rspPageRspBase.success()) {
            setValue("onPageSuccess", rspPageRspBase.getData());
        } else {
            setValue("onPageSuccess");
        }
    }

    @Override
    public void onFail(HandleException e) {
        setValue("onPageSuccess");
    }


    public void pagetFL(int nowPage) {
        this.execute(new ReqWelfareNote(nowPage), new IResult<RspBase<RspPage<ENote>>>() {
            @Override
            public void onSuccess(RspBase<RspPage<ENote>> rspPageRspBase) throws Exception {
                if (rspPageRspBase.success()) {
                    setValue("onPageSuccess", rspPageRspBase.getData());
                } else {
                    setValue("onPageSuccess");
                }
            }

            @Override
            public void onFail(HandleException e) {
                setValue("onPageSuccess");
            }
        });
    }

}
